package com.sg.service.base.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.entity.OmsEvaluationTemplateFillSet;
import com.sg.service.base.app.MOmsEvaluationTemplateFillSetService;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.dal.mapper.mbg.OmsEvaluationTemplateFillSetMapper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author ：
 * @version 1.0
 * @since 2022/1/19 15:39
 */
@Service
public class MOmsEvaluationTemplateFillSetServiceImpl
        extends ServiceImpl<OmsEvaluationTemplateFillSetMapper, OmsEvaluationTemplateFillSet>
        implements MOmsEvaluationTemplateFillSetService {

    @Autowired
    OmsEvaluationTemplateFillSetMapper omsEvaluationTemplateFillSetMapper;

    /**
     * 3-3-12查询评价模板填报设置列表[4223]
     * gen by moon at 10/10/2022, 1:27:37 AM
     */
    @Trace(operationName = "3-3-12查询评价模板填报设置列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsEvaluationTemplateFillSet> queryEvaTempFillSetList(OmsEvaluationTemplateFillSet omsEvaluationTemplateFillSet) {

        try {
            QueryWrapper<OmsEvaluationTemplateFillSet> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(omsEvaluationTemplateFillSet);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsEvaluationTemplateFillSet.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsEvaluationTemplateFillSet.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsEvaluationTemplateFillSet.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsEvaluationTemplateFillSet>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-12批量删评价模板填报设置[4224]
     * gen by moon at 10/10/2022, 1:27:37 AM
     */
    @Trace(operationName = "3-3-12批量删评价模板填报设置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteEvaTempFillSet(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

}

